﻿using Ln.Fram.SqlSugarCore.Abstractions;
using Ln.Rbac.Domain.Entities;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;

namespace Ln.Rbac.SqlSugarCore.DataSeeds;

public class PostDataSeed : IDataSeedContributor, ITransientDependency
{
	#region 构造函数
	public PostDataSeed(ISqlSugarRepository<PostAggregateRoot> repository) => _repository = repository;
	#endregion

	#region 成员属性
	private ISqlSugarRepository<PostAggregateRoot> _repository;
	#endregion

	#region 自身方法
	public async Task SeedAsync(DataSeedContext context) { if (!await _repository.IsAnyAsync(x => true)) await _repository.InsertManyAsync(GetSeedData()); }

	private List<PostAggregateRoot> GetSeedData()
	{
		var entites = new List<PostAggregateRoot>();
		entites.AddRange([
			new() { PostName = "董事长", PostCode = "ceo", OrderNum = 100, IsDeleted = false, State = true },
			new() { PostName = "项目经理", PostCode = "se", OrderNum = 100, IsDeleted = false, State = true },
			new() { PostName = "人力资源", PostCode = "hr", OrderNum = 100, IsDeleted = false, State = true },
			new() { PostName = "普通员工", PostCode = "user", OrderNum = 100, IsDeleted = false, State = true },
		]);
		return entites;
	}
	#endregion
}
